<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Customer_Model extends CI_Model
{

	function add($data, $return){

		$tabelname = 'customer';

		if ($this->db->insert($tabelname, $data)) {

			$field_id = $this->db->insert_id();

			if($return) return $field_id;

		}

		return TRUE;
	}

	function get_customer_by_user_id($user_id){
		$this->db->where('user_id', $user_id);

		$query = $this->db->get('customer');

		if ($query->num_rows() > 0 ) return $query->row();

		return NULL;
	}

	function get_customer_by_id($customer_id){
		$this->db->where('customer_id', $customer_id);

		$query = $this->db->get('customer');

		if ($query->num_rows() > 0 ) return $query->row();

		return NULL;
	}

}